<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>PagerMaid</title>
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
    <link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.min.css" />
    <link rel="stylesheet" href="style.css" />
    <script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
</head>

<body>
    <div class="demo-layout mdl-layout mdl-js-layout mdl-layout--fixed-drawer mdl-layout--fixed-header">
        <header class="demo-header mdl-layout__header mdl-color--grey-100 mdl-color-text--grey-600">
            <div class="mdl-layout__header-row">
                <span class="mdl-layout-title">Dashboard</span>
            </div>
        </header>
{% include 'includes/navbar.html' %}
        <main class="mdl-layout__content mdl-color--grey-100">
            <div class="mdl-grid demo-content">

                <div
                    class="mdl-card mdl-shadow--2dp mdl-cell mdl-cell--4-col mdl-cell--4-col-tablet mdl-cell--12-col-desktop">
                    <div class="mdl-card__title">
                        <h2 class="mdl-card__title-text">Status</h2>
                    </div>
                    <div class="mdl-card__supporting-text">
                        <table class="mdl-data-table w-100 mdl-js-data-table">
                            <!--<thead>
                                <tr>
                                    <th class="mdl-data-table__cell&#45;&#45;non-numeric">Node</th>
                                    <th>Value</th>
                                </tr>
                            </thead>-->
                            <tbody>
                                <tr>
                                    <td class="mdl-data-table__cell--non-numeric">Hostname</td>
                                    <td>{{ hostname }}</td>
                                </tr>
                                <tr>
                                    <td class="mdl-data-table__cell--non-numeric">Platform</td>
                                    <td>{{ platform }}</td>
                                </tr>
                                <tr>
                                    <td class="mdl-data-table__cell--non-numeric">Kernel Version</td>
                                    <td>{{ kernel }}</td>
                                </tr>
                                <tr>
                                    <td class="mdl-data-table__cell--non-numeric">Python Version</td>
                                    <td>{{ python }}</td>
                                </tr>
                                <tr>
                                    <td class="mdl-data-table__cell--non-numeric">Library Version</td>
                                    <td>{{ telethon }}</td>
                                </tr>
                                <tr>
                                    <td class="mdl-data-table__cell--non-numeric">Database Status</td>
                                    <td>{{ redis }}</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div
                    class="mdl-card mdl-shadow--2dp mdl-cell mdl-cell--4-col mdl-cell--4-col-tablet mdl-cell--12-col-desktop">
                    <div class="mdl-card__title">
                        <h2 class="mdl-card__title-text">Memory</h2>
                    </div>
                    <div class="mdl-card__supporting-text">
                        <table class="mdl-data-table w-100 mdl-js-data-table">
                            <tbody>
                                <tr>
                                    <td class="mdl-data-table__cell--non-numeric mdl-typography--font-bold">
                                        Total available
                                    </td>
                                    <td>
                                        <div class="mdl-progress mdl-js-progress" data-progress="{{ memory_available_percentage }}"></div>
                                    </td>
                                    <td>{{ memory_available }} MiB / {{ memory_total }} MiB ({{ memory_available_percentage }}%)</td>
                                </tr>
                                <tr>
                                    <td class="mdl-data-table__cell--non-numeric mdl-typography--font-bold">Free</td>
                                    <td>
                                        <div class="mdl-progress mdl-js-progress" data-progress="{{ memory_free_percentage }}"></div>
                                    </td>
                                    <td>{{ memory_free }} MiB / {{ memory_total }} MiB ({{ memory_free_percentage }}%)</td>
                                </tr>
                                <tr>
                                    <td class="mdl-data-table__cell--non-numeric mdl-typography--font-bold">Buffered</td>
                                    <td>
                                        <div class="mdl-progress mdl-js-progress" data-progress="{{ memory_buffered_percentage }}"></div>
                                    </td>
                                    <td>{{ memory_buffered }} MiB / {{ memory_total }} MiB ({{ memory_buffered_percentage }}%)</td>
                                </tr>
                                <tr>
                                    <td class="mdl-data-table__cell--non-numeric mdl-typography--font-bold">Cached</td>
                                    <td>
                                        <div class="mdl-progress mdl-js-progress" data-progress="{{ memory_cached_percentage }}"></div>
                                    </td>
                                    <td>{{ memory_cached }} MiB / {{ memory_total }} MiB ({{ memory_cached_percentage }}%)</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </main>
    </div>

    <script>
        document.querySelectorAll('.mdl-progress').forEach(function(el) {
            el.addEventListener('mdl-componentupgraded', function () {
                var progress = parseInt(this.dataset.progress || 0);
                this.MaterialProgress.setProgress(progress <= 100 ? progress : 100);
            });
        })
    </script>
</body>

</html>